package com.homesoft.runtime.metadata.modle;

public class ExtendDataItem extends ValueChangeNotifier implements IExtendDataItem {

	private String _key;
	private String _value;
	private boolean _inherited;

	public ExtendDataItem(String key, String value) {
		this._key = key;
		this._value = value;
	}

	@Override
	public boolean isInherited() {
		return _inherited;
	}

	@Override
	public void setInherited(boolean inherited) {
		if (NotifyEnabled()) {
			boolean oldValue = this._inherited;
			this._inherited = inherited;
			OnPropertyChanged("Inherited", oldValue, inherited);
		} else {
			this._inherited = inherited;
		}
	}

	@Override
	public String getKey() {
		return _key;
	}

	@Override
	public void setKey(String key) {
		if (this._key == key)
			return;
		String oldValue = this._key;
		if (NotifyEnabled()) {
			boolean cancel = this.OnPropertyChanging("Key", oldValue, key);
			if (cancel) {
				return;
			}
		}
		IExtendDataList list = (IExtendDataList) this.getOwner();
		if (list != null) {
			if (!list.ChangeItemKey(this, key)) {
				return;
			}
		}
		this._key = key;
		if (NotifyEnabled()) {
			OnPropertyChanged("Key", oldValue, key);
		}
	}

	@Override
	public String getValue() {
		return _value;
	}

	@Override
	public void setValue(String value) {
		if (NotifyEnabled()) {
			String oldValue = this._value;
			this._value = value;
			OnPropertyChanged("Value", oldValue, value);
		} else {
			this._value = value;
		}
	}
}
